package com.stlm2.controller;

import com.stlm2.dems.service.DdmGoodPropertyService;
import com.stlm2.dems.service.ValueAddedServicesService;
import com.stlm2.util.codecontent.CodeContent;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;

/**
 * Created by zlq on 2017/10/18.
 */
@Controller
@RequestMapping("/ddmGoodPropertyC")
public class DdmGoodPropertyController {
    @Resource
    private DdmGoodPropertyService ddmGoodPropertyService;
    /*zlq
* crm查询商品基础属性列表页面
* */
    @RequestMapping(value="/listView",produces="application/json;charset=UTF-8")
    public ModelAndView listView(ModelAndView modelAndView){
        modelAndView.setViewName("/ddmGoodProperty/list");
        return modelAndView;
    }

    /*
*查询所有的商品属性名称
* zlq
 */
    @ResponseBody
    @RequestMapping(value="/getAllGoodPropertyName.json",produces="application/json;charset=UTF-8")
    public  String getAllGoodPropertyName(ModelMap model){
        String data=null;
        try {
            data=ddmGoodPropertyService.getAllGoodPropertyName(model);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"查询失败",data);
        }
        return  data;
    }

    /*
*CRM查询增值服务列表
* zlq
* token:
* page:页码
*/
    @ResponseBody
    @RequestMapping(value="/getList.json",produces="application/json;charset=UTF-8")
    public  String getList(ModelMap model,String token ,String page){
        String data=null;
        try {
            data=ddmGoodPropertyService.getList(model,token,page);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"查询失败",data);
        }
        return  data;
    }
/*
*zlq
* 添加商品基础属性
* token:
* name:名称
* label：标签
 */
    @ResponseBody
    @RequestMapping(value="/add.json",produces="application/json;charset=UTF-8")
    public  String add(ModelMap model, String token,String name,String label){
        String data=null;
        try {
            data=ddmGoodPropertyService.add(model,token,name,label);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"查询失败",data);
        }
        return  data;
    }

    @ResponseBody
    @RequestMapping(value="/getAllGoodPropertyName2.json",produces="application/json;charset=UTF-8")
    public  String getAllGoodPropertyName2(ModelMap model,String goodsId){
        String data=null;
        try {
            data=ddmGoodPropertyService.getAllGoodPropertyName2(model,goodsId);
        }catch (Exception e){
            e.printStackTrace();
            return  CodeContent.getModelByCode(0,"查询失败",data);
        }
        return  data;
    }

}
